package com.yto.hrreport.event.buttons
{
	import com.yto.hrreport.command.ReportCommand;
	import com.yto.hrreport.event.buttons.superbutton.ButtonEvent;
	
	import flash.events.MouseEvent;
	
	import mx.controls.TextInput;

	public class AddButtonEvent extends ButtonEvent
	{
		
		private static var addEvent : AddButtonEvent = new AddButtonEvent();
		private var param : Object;
		private static var parentName : String;
		public function AddButtonEvent() {
			super();
		}
		
		public static function getInstance(parentName : String) : AddButtonEvent {
			AddButtonEvent.parentName = parentName;
			return addEvent;
		}
		
		public function addHandler(event:MouseEvent) : void {
			
			param = ReportCommand.getInstance(parentName).initParam("onBoAdd");
			
			param.headGrid.visible = false;
			param.bodyGrid.top = 5;
			
			if(param.headCard == null) {
				param.headCard = ReportCommand.getInstance(parentName).createHeadCard(param.parentCanvas);
			} else 
				param.headCard.visible = true;
			
			param.bodyGrid.dataProvider = null;
			TextInput(param.headCard.getChildByName(parentName + "_txtPeriod")).text = null;
			
			updateButtons(event , "add" , param.headCanvas , true);
		}
	}
}